package com.oscchina.xushao.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.oscchina.xushao.R;
import com.oscchina.xushao.app.AppContext;
import com.oscchina.xushao.type.Category;

public class DrawerAdapter extends BaseAdapter {

    private ListView mListView;

    public DrawerAdapter(ListView listView) {
        mListView = listView;
    }

    @Override
    public int getCount() {
        return Category.TITLES.length;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

//    @Override
//    public int getItem(int position) {
//        return position;
//    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(AppContext.getContext()).inflate(R.layout.fragment_navigation_drawer_list_item, null);
        }
        ImageView imageView = (ImageView) convertView.findViewById(R.id.drawer_item_logo);
        TextView textView = (TextView) convertView.findViewById(R.id.drawer_item_title);
        imageView.setImageResource(Category.ICONS[position]);
        textView.setText(Category.TITLES[position]);
        textView.setSelected(mListView.isItemChecked(position));
        return convertView;
    }

}
